﻿namespace WFBot.Framework.Web.Controllers
{
    using System.Web.Mvc;
    using Workflow;

    public class BotController : Controller
    {
        private readonly IWorkflowService _workflowService;

        public BotController(IWorkflowService workflowService)
        {
            _workflowService = workflowService;
        }

        public ActionResult Index()
        {
            ViewData.Model = Session.SessionID;
            return View();
        }

        [HttpPost]
        public JsonResult Init(string channel)
        {
            _workflowService.Run<SelectOperator>(channel);
            return Json(true);
        }

        [HttpPost]
        public JsonResult Push(Message message)
        {
            _workflowService.Push(message);
            return Json(true);
        }

        [HttpPost]
        public JsonResult Pull(string channel)
        {
            return Json(_workflowService.Pull(channel));
        }
    }
}